package io.github.lianghengyuan.international.config;

import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.i18n.CookieLocaleResolver;

import java.util.Locale;

/**
 * 资源文件配置加载
 *
 * @author ruoyi
 */

@Configuration
@AutoConfigureBefore(WebMvcAutoConfiguration.class)
public class I18nConfig
{
    @Bean
    public LocaleResolver localeResolver()
    {
        CookieLocaleResolver clr = new CookieLocaleResolver();
        // 默认语言
        clr.setDefaultLocale(Locale.SIMPLIFIED_CHINESE);
        clr.setCookieName("language");
        return clr;
    }

}
